package com.example;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@Slf4j
@RestController
public class CloudOauthApplication {

    @GetMapping("/user/me")
    public Authentication principal() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.err.println(authentication.getClass().getSimpleName());
        log.info("user-me:{}", authentication.getName());
        return authentication;
    }

    public static void main(String[] args) {
        SpringApplication.run(CloudOauthApplication.class, args);
    }
}
